﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Blog.Model
{
    public class ApiResult
    {
        public bool IsSuccess { get; set; }
        public object Data { get; set; }

        /// <summary>
        /// 总条数
        /// </summary>
        public int TotalCount { get; set; } = 0;
        public string Msg { get; set; }

        public ApiResult()
        {

        }

        public ApiResult Error(string msg)
        {
            this.IsSuccess = false;
            this.Msg = msg;
            return this;
        }

        public ApiResult OK() 
        { 
            this.IsSuccess = true;
            this.Msg = "成功";
            return this; 
        }

        public ApiResult OK(string msg)
        {
            this.IsSuccess = true;
            this.Msg = msg;
            return this;
        }

        public ApiResult OK(object data)
        {
            this.IsSuccess = true;
            this.Msg = "成功";
            this.Data = data;
            return this;
        }
        public ApiResult OK(object data,int totalCount)
        {
            this.IsSuccess = true;
            this.Msg = "成功";
            this.Data = data;
            this.TotalCount = totalCount;
            return this;
        }
    }
}
